<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改品牌</title>
    <link href="css/update.css" rel="stylesheet">
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://unpkg.com/vue@2.7.16/dist/vue.js"></script>

</head>
<body>
<div id="app">
    <h3>修改品牌</h3>
    <table>
        <tr>
            <td>品牌名称：</td>
            <td><input id="brandName" name="brandName" v-model="brand.brandName"></td>
        </tr>
        <tr>
            <td>企业名称：</td>
            <td><input id="companyName" name="companyName" v-model="brand.companyName"></td>
        </tr>
        <tr>
            <td>排序：</td>
            <td><input id="ordered" name="ordered" v-model="brand.ordered"></td>
        </tr>
        <tr>
            <td>描述信息：</td>
            <td><textarea id="description" rows="5" cols="20" name="description" v-model="brand.description"></textarea>
            </td>
        </tr>
        <tr>
            <td>状态：</td>
            <td id="status">
                <input class="status" type="radio" name="status" value="0" v-model="brand.status">禁用
                <input class="status" type="radio" name="status" value="1" v-model="brand.status">启用<br>
            </td>
        </tr>
        <tr>
            <td colspan="2"><input id="button" type="button" value="提交" @click="submit"></td>
        </tr>
    </table>
</div>
<script>
    new Vue({
        el: "#app",
        data() {
            return {
                brand: {
                    id:'',
                    brandName: '',
                    companyName: '',
                    ordered: '',
                    description: '',
                    status: '',
                }
            }
        },
        mounted() {
            let _this = this;
            _this.brand.id = "${brand.id}"
            _this.brand.brandName = "${brand.brandName}"
            _this.brand.companyName = "${brand.companyName}"
            _this.brand.ordered = "${brand.ordered}"
            _this.brand.description = "${brand.description}"
            _this.brand.status = "${brand.status}"
        },
        methods: {
            submit() {
                let _this = this;
                axios.post("http://localhost:8080/LoginAndRegistration/updateServlet", _this.brand).then(function (resp) {
                    if (resp.status === 200) {
                        location.href = "http://localhost:8080/LoginAndRegistration/brand.jsp";
                    }
                })
            }
        }
    })
</script>
</body>
</html>